<%-- 
    Document   : Study_Plan
    Created on : 12-mag-2012, 16.02.46
    Author     : Daniel
--%>

<%@page import="Utils.Corso"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Study plan</title>

  <link rel="stylesheet" type="text/css" href="css/bootstrap.css"> <!-- Chiamata al css contenente la grafica -->
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/bootstrap.min.js"></script>
 
<style type="text/css">
        #selectable .ui-selecting { background: #FFFFFF; }
	#selectable .ui-selected { background: #99CBFF; color: black; border: #34FF12; }
</style>
 
<jsp:useBean id="plan1" scope="request" type="Utils.StudyPlan"></jsp:useBean>
<jsp:useBean id="plan2" scope="request" type="Utils.StudyPlan"></jsp:useBean>
<jsp:useBean id="plan3" scope="request" type="Utils.StudyPlan"></jsp:useBean>


<script>
    
    
            $(document).ready(function (){
                var x = $(document).height();
                $('#Bottom_bar').css("top", (x+618)+"px");
                $('#Menu_background').css("height" , (x+500)+"px");
                $('#tabs li:eq(<% if(plan1.isModificabile()) out.append("0");
                                          else if(plan2.isModificabile()) out.append("1");
                                                        else out.append("2");
                                %>) a').tab('show');
            });

</script> 

  <script type="text/javascript">
      $(function() {
		$("a.cambiavoto").click(function() {
                    $('#Bottom_bar').css("top", "+=50");
                    $('#Menu_background').css("height" , "+=50");
                    
                    var x = $(this).parent().attr("id");
                        $(this).parent().html(
             
   "<form method=\"get\" action=\"Study_Plan\">"
   +"<fieldset>"
   +"<input type=\"text\" class=\"input-small\" name=\"voto\" ><br> "
   +"</fieldset> "
   +"<input type=\"hidden\" name=\"corso_id\" value=\""+ x +"\" >"   
   +"<input type=\"submit\" name=\"operazione\" value=\"Canc\">"
   +"<input type=\"submit\" name=\"operazione\" value=\"OK\"> "
   +"</form>"
   );

            })
	});

</script>

</head>

<body>

<div id="Menu_background"> </div>
<div id="Top_bar"> </div>
<div id="Bottom_bar"> </div>

<div id="Header">

	<div id="LOGO_UNITN" class="image" style="position:absolute;left:26px;top:15px;width:339px;height:93px;z-index:0;padding:0;">
	<img src="images/logo_unitn1.gif" id="Image1" alt="" border="0" style="width:339px;height:93px;"></div>
        
</div>

<div id="SlideMenu1">
    <ul class="nav nav-list">
  <li class="nav-header">
    studente
  </li>
  <li>
    <a href="Home_Studente">Home</a>
  </li>
  <li class="active">
    <a href="Study_Plan">Study Plan</a>
  </li>
  <li>
    <a href="Corsi_Studente">Corsi</a>
  </li>
  <li>
    <a href="Logout">Logout</a>
  </li>
</ul>
</div>

<div class="modal fade" id="myModal">
            <div class="modal-header">
            <button class="close" data-dismiss="modal">×</button>
            <h3>Invio richiesta approvazione plan all'advisor</h3>
            </div>  
            <div class="modal-body">
                <form class="form-horizontal" method="post" action="mailing">
                <fieldset>
                    <div class="control-group">
                        <label class="control-label" for="messaggio">Messaggio aggiuntivo</label>
                        <div class="controls">
                            <textarea class="input-xlarge" rows="6" style="resize:none;" id="messaggio"> </textarea>
                        <p class="help-block">I messaggi aggiuntive saranno appesi alla mail di richiesta</p>
                        </div>
                     </div>
                     <div class="form-actions">
                        <button type="submit" class="btn btn-primary">Invia richiesta</button>
                        <button class="btn btn-danger" data-dismiss="modal" >Cancel</button>
                     </div>
                 </fieldset>
                </form>
             </div>
        </div> 

<div id="wb_Text3" style="position:absolute;left:190px;top:162px">
    <h3>Study Plan</h3></div>

    <div style="position:absolute;left:190px;top:190px">   
    <ul class="nav nav-tabs" id="tabs">
        <li><a href="#tab1" data-toggle="tab"><h4>Study Plan <% out.append(plan1.getAnno()-1 + "/" + plan1.getAnno()); %></h4></a></li>
        <li><a href="#tab2" data-toggle="tab"><h4>Study Plan <% out.append(plan2.getAnno()-1 + "/" + plan2.getAnno()); %></h4></a></li>
        <li><a href="#tab3" data-toggle="tab"><h4>Study Plan <% out.append(plan3.getAnno()-1 + "/" + plan3.getAnno()); %></h4></a></li>
    </ul> 
        
    <div class="tab-content"> 
        
    <div class="tab-pane" id="tab1">
    	<div>
            <h4>Piano di studio : 
                        <%  if(plan1.isApprovato()) 
                                out.append("Approvato"); 
                            else 
                                out.append("Non approvato");
                        %> 
            </h4>
        </div>
        <% 
        if(plan1.isModificabile())
            {
        %>
		<button class ="btn" data-toggle="modal" data-target = "#myModal"  type="button" id="approvazione_plan1" style="position:absolute;left:80%;" <% if(!plan1.isValido()) out.append("disabled"); %>>Richiedi approvazione</button>
        <%
        }
        %>
                
		<div>
                    <h5>
                    <%
                    if(plan1.isValido()) out.append("Il piano è valido");
                           else out.append("Il piano non è valido");
                    %>
                    </h5>
                    <h6>
                    Crediti Totali <% out.append( (plan1.getCrediti_esterni()+plan1.getCrediti_interni())+ "/" + plan1.getCrediti_necessari()); %>
                    <br>Crediti corsi interni minimi <% out.append(plan1.getCrediti_interni()+ "/" + plan1.getCrediti_interni_necessari()); %>
                    <br>Crediti corsi esterni <% out.append("" +plan1.getCrediti_esterni()); %>
                    </h6>
                </div>
                <br>
        <table class="table table-bordered">
		<tr>
		<th  style="width:180px"> 
                Nome
		</th>
		<th  style="width:120px"> 
                Periodo
		</th>
                <th style="width:60px">
                Crediti
                </th>
                <th style="width:60px">
		Tipo
		</th>
		<th  style="width:210px">
		Link
		</th>
                <th  style="width:150px">
		Docente
		</th>
                <th  style="width:150px">
		Email docente
		</th>
		<th  style="width:120px">
		Stato
		</th>
                <th  style="width:120px">
                Voto
                </th>
                </tr>
                <c:forEach items="${plan1.getPlan().values()}" var="plan">
                    <tr>
                    <td><a href="<c:url value="Corsi_Studente?corso_target=${plan.id}"/>"><c:out value="${plan.nome}"/></a></td>
                        <td ><c:out value="${plan.periodo}"/></td>
                        <td ><c:out value="${plan.crediti}"/></td>
                        <td >
                            <c:choose>
                                <c:when test="${plan.esterno}">
                                    Esterno
                                </c:when>
                                <c:otherwise>
                                    Interno
                                </c:otherwise>
                            </c:choose>   
                        </td>
                        <td ><a href="<c:url value="${plan.url}"/>"><c:out value="${plan.url}"/></a></td>
                        <td ><c:out value="${plan.nome_docente}"/></td>
                        <td ><c:out value="${plan.email}"/></td>
                        <td >
                            <c:choose>
                                <c:when test="${plan.approvato}">
                                    Approvato
                                </c:when>
                                <c:otherwise>
                                    Non approvato
                                </c:otherwise>
                            </c:choose>
                        </td>
                        <td id="${plan.id}">
                            <c:choose>
                                <c:when test="${plan.completato}">
                                    <c:out value="${plan.voto}"/>
                                </c:when>
                                <c:otherwise>
                                    <c:if test="${plan.esterno}">
                                       <c:out value="${plan.voto}"/> <a href="#" class="cambiavoto"> (Autocertifica) </a>
                                    </c:if>
                                </c:otherwise>                      
                            </c:choose>
                         </td>  
                    </tr>
                </c:forEach>
		</table>
        
        <br> 
        
    </div>
    <div class="tab-pane" id="tab2">
    
    	<div>
                 <h4>Piano di studio : 
                        <%  if(plan2.isApprovato()) 
                                out.append("Approvato"); 
                            else 
                                out.append("Non approvato");
                        %> 
                 </h4>
        </div>

        <% 
        if(plan2.isModificabile())
            {
        %>
                
		<button class ="btn" type="button" data-toggle="modal" data-target = "#myModal"  id="approvazione_plan2" style="position:absolute;left:80%;" <% if(!plan2.isValido()) out.append("disabled"); %>>Richiedi approvazione</button>
        
        <%
        }
        %>
		<div>
                    <h5>
                    <%
                    if(plan2.isValido()) out.append("Il piano è valido");
                           else out.append("Il piano non è valido");
                    %>
                    </h5>   
                <h6>
                    Crediti Totali <% out.append( (plan2.getCrediti_esterni()+plan2.getCrediti_interni()) + "/" + plan2.getCrediti_necessari()); %>
                    <br>Crediti corsi interni minimi <% out.append(plan2.getCrediti_interni()+ "/" + plan2.getCrediti_interni_necessari()); %>
                    <br>Crediti corsi esterni <% out.append("" +plan2.getCrediti_esterni()); %>
                </h6>
                </div>
                <br>
        <table class="table table-bordered">
		<tr>
		<th  style="width:180px"> 
                Nome
		</th>
		<th  style="width:120px"> 
                Periodo
		</th>
                <th style="width:60px">
                Crediti
                </th>
                <th style="width:60px">
		Tipo
		</th>
		<th  style="width:210px">
		Link
		</th>
                <th  style="width:150px">
		Docente
		</th>
		<th  style="width:150px">
		Email docente
		</th>
		<th  style="width:120px">
		Stato
		</th>
                <th  style="width:120px">
                Voto
                </th>
                </tr>
                <c:forEach items="${plan2.getPlan().values()}" var="plan">
                    <tr>
                    <td><a href="<c:url value="Corsi_Studente?corso_target=${plan.id}"/>"><c:out value="${plan.nome}"/></a></td>
                        <td ><c:out value="${plan.periodo}"/></td>
                        <td ><c:out value="${plan.crediti}"/></td>
                        <td >
                            <c:choose>
                                <c:when test="${plan.esterno}">
                                    Esterno
                                </c:when>
                                <c:otherwise>
                                    Interno
                                </c:otherwise>
                            </c:choose>   
                        </td>
                        <td ><a href="<c:url value="${plan.url}"/>"><c:out value="${plan.url}"/></a></td>
                        <td ><c:out value="${plan.nome_docente}"/></td>
                        <td ><c:out value="${plan.email}"/></td>
                        <td >
                            <c:choose>
                                <c:when test="${plan.approvato}">
                                    Approvato
                                </c:when>
                                <c:otherwise>
                                    Non approvato
                                </c:otherwise>
                            </c:choose>
                        </td>
                        <td id="${plan.id}">
                            <c:choose>
                                <c:when test="${plan.completato}">
                                    <c:out value="${plan.voto}"/>
                                </c:when>
                                <c:otherwise>
                                    <c:if test="${plan.esterno}">
                                       <c:out value="${plan.voto}"/> <a href="#" class="cambiavoto"> (Autocertifica) </a>
                                    </c:if>
                                </c:otherwise>                      
                            </c:choose>
                         </td>  
                    </tr>
                </c:forEach>
		</table>
        
        <br>
    
    </div>
                
    <div class="tab-pane" id="tab3">
    
   		<div>
                    <h4>Piano di studio : 
                        <%  if(plan3.isApprovato()) 
                                out.append("Approvato"); 
                            else 
                                out.append("Non approvato");
                        %> 
                    </h4>
                </div>

        <% 
        if(plan3.isModificabile())
            {
        %>
                
	<button class ="btn" type="button" data-toggle="modal" data-target = "#myModal"  id="approvazione_plan3" style="position:absolute;left:80%;" <% if(!plan1.isValido()) out.append("disabled"); %>>Richiedi approvazione</button>
        
        <%
        }
        %>
        
        
		<div>
                    <h5>
                    <%
                    if(plan3.isValido()) out.append("Il piano è valido");
                           else out.append("Il piano non è valido");
                    %>
                    </h5> 
                    <h6>
                    Crediti Totali <% out.append((plan3.getCrediti_esterni()+plan3.getCrediti_interni())+ "/" + plan3.getCrediti_necessari()); %>
                    <br>Crediti corsi interni minimi <% out.append(plan3.getCrediti_interni()+ "/" + plan3.getCrediti_interni_necessari()); %>
                    <br>Crediti corsi esterni <% out.append("" +plan3.getCrediti_esterni()); %>
                    </h6>
                </div>
                <br>
    	<table class="table table-bordered">
		<tr>
		<th  style="width:180px"> 
                Nome
		</th>
		<th  style="width:120px"> 
                Periodo
		</th>
                <th style="width:60px">
                Crediti
                </th>
                <th style="width:60px">
		Tipo
		</th>
		<th  style="width:210px">
		Link
		</th>
                <th  style="width:150px">
		Docente
		</th>
		<th  style="width:150px">
		Email docente
		</th>
		<th  style="width:120px">
		Stato
		</th>
                <th  style="width:120px">
                Voto
                </th>
                </tr>
                <c:forEach items="${plan3.getPlan().values()}" var="plan">
                    <tr>
                    <td><a href="<c:url value="Corsi_Studente?corso_target=${plan.id}"/>"><c:out value="${plan.nome}"/></a></td>
                        <td ><c:out value="${plan.periodo}"/></td>
                        <td ><c:out value="${plan.crediti}"/></td>
                        <td >
                            <c:choose>
                                <c:when test="${plan.esterno}">
                                    Esterno
                                </c:when>
                                <c:otherwise>
                                    Interno
                                </c:otherwise>
                            </c:choose>   
                        </td>
                        <td ><a href="<c:url value="${plan.url}"/>"><c:out value="${plan.url}"/></a></td>
                        <td ><c:out value="${plan.nome_docente}"/></td>
                        <td ><c:out value="${plan.email}"/></td>
                        <td >
                            <c:choose>
                                <c:when test="${plan.approvato}">
                                    Approvato
                                </c:when>
                                <c:otherwise>
                                    Non approvato
                                </c:otherwise>
                            </c:choose>
                        </td>
                        <td id="${plan.id}">
                            <c:choose>
                                <c:when test="${plan.completato}">
                                    <c:out value="${plan.voto}"/>
                                </c:when>
                                <c:otherwise>
                                    <c:if test="${plan.esterno}">
                                       <c:out value="${plan.voto}"/> <a href="#" class="cambiavoto"> (Autocertifica) </a>
                                    </c:if>
                                </c:otherwise>                      
                            </c:choose>
                         </td>  
                    </tr>
                </c:forEach>
		</table>
        
                <br>
    </div>
    </div>
    </div>
</body>
</html>